﻿/*using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp.TestFunc
{
    internal class remarks
    {
        internal class Program
        {

            static void Main(string[] args)
            {
                Action<string> printMessage = msg => Console.WriteLine(msg);

                string num = Console.ReadLine();
                if (num.Equals("x"))
                {
                    printMessage("info");
                }
                else
                {
                    printMessage("你好");
                }


                Console.ReadKey();
            }

            private static void PrintNum<T>(IEnumerable<T> enumer)
            {
                foreach (T num in enumer)
                {
                    Console.WriteLine(num);
                }
            }
        }


        #region 依赖注入测试
        //做一个容器的生成类
        *//*ServiceCollection containerBuilder = new ServiceCollection();


        //ServiceDescriptor descriptor:
        //1、服务的类型
        //2、服务的实现类型
        //3、服务的生命周期 transient singleton scoped

        //单例每次调用都是同一个服务
        //作用域 session会话在一个会话里面，scoped是同一个服务
        //瞬时服务，每一次调用，都是一个新的对象


        //注册容器里的服务信息
        containerBuilder.AddSingleton<Car>();
        containerBuilder.AddTransient<IBattery, BatteryB>();
        containerBuilder.AddScoped<IBattery, BatteryA>();

        //生成我们的容器
        IServiceProvider container = containerBuilder.BuildServiceProvider();
        containerBuilder.MakeReadOnly();


        //通过容器进行服务的调用
        Car? car = container.GetService<Car>();

        TcpClientTest test = new TcpClientTest();
        test.RunTest();
        Console.WriteLine("客户端测试已经启动。。。。。。。。");

        Console.ReadKey();


        TcpServer server = new TcpServer();
        server.Start();
        Console.WriteLine("服务器监听已经启动。。。。。。。。");*//*
        #endregion
        public class Car
        {
            private readonly IBattery _battery;
            public Car(IBattery battery)
            {
                _battery = battery;
            }
            public void Start()
            {
                _battery.Supply(2);
            }
        }

        public interface IBattery
        {
            double Capacity { get; set; }
            void Supply(double consumption);
            double GetCapacity();
        }

        public class BatteryA : IBattery
        {
            public double Capacity { get; set; }


            public void Supply(double consumption)
            {
                Capacity -= consumption;
            }
            public double GetCapacity() => Capacity;
        }


        public class BatteryB : IBattery
        {
            public double Capacity { get; set; }


            public void Supply(double consumption)
            {
                Capacity -= consumption;
            }
            public double GetCapacity() => Capacity;
        }
    }
}
*/